﻿using System;

namespace ExceptionTest
{
    enum gender
    {
        male,
        female
    }

    class Student
    {
        private string name;
        private gender studentGender;
        private int age;
        private int classNumber;
        private int sSN;
        private DateTime birthday;

        public string Name
        {
            get
            {
                return name;
            }
            set 
            {
                if (value.Length < 10 || value.Length > 50)
                {
                    throw new InvalidStudentException("Name length should be between 10 and 50", 
                                                      value.Length, new ArgumentException());
                }
                name = value; 
            }
        }

        internal gender StudentGender
        {
            get
            {
                return studentGender;
            }
            set
            {
                studentGender = value;
            }
        }

        public int Age
        {
            get
            {
                return age;
            }
            set 
            {
                if (value < 7 || value > 18)
                {
                    throw new InvalidStudentException("Age should be between 7 and 50",
                                                      value, new ArgumentException());
                }
                age = value;
            }
        }

        public int ClassNumber
        {
            get
            {
                return classNumber;
            }
            set 
            {
                if (value < 1 || value > 11)
                {
                    throw new InvalidStudentException("Class should be between 1 and 11",
                                                      value, new ArgumentException());
                }
                classNumber = value; 
            }
        }

        public int SSN
        {
            get
            {
                return sSN;
            }
            set 
            {
                if (value < 100000000 || value > 999999999)
                {
                    throw new InvalidStudentException("SSN should be a ninedigit number",
                                                      value, new ArgumentException());
                }
                sSN = value;
            }
        }

        public DateTime Birthday
        {
            get
            {
                return birthday;
            }
            set 
            {
                if (value.Year < 1900 || value.Year > 2009)
                {
                    throw new InvalidStudentException("Year should be between 1900 and 2009",
                                                      value.Year, new ArgumentException());
                }
                birthday = value;
            }
        }

        public Student()
        {
            this.name = "Pesho";
            this.studentGender = gender.male;
            this.age = 7;
            this.classNumber = 1;
            this.sSN = 100000000;
            this.birthday = new DateTime(1900, 1, 1);
        }

        public Student(string name, gender studentGender, int age, int classNumber, int sSN, DateTime birthday)
        {
            if (name.Length < 10 || name.Length > 50)
            {
                throw new InvalidStudentException("Name length should be between 10 and 50",
                                                  name.Length, new ArgumentException());
            }
            this.name = name;

            this.studentGender = studentGender;

            if (age < 7 || age > 18)
            {
                throw new InvalidStudentException("Age should be between 7 and 50",
                                                  age, new ArgumentException());
            }
            this.age = age;

            if (classNumber < 1 || classNumber > 11)
            {
                throw new InvalidStudentException("Class should be between 1 and 11",
                                                  classNumber, new ArgumentException());
            }
            this.classNumber = classNumber;

            if (sSN < 100000000 || sSN > 999999999)
            {
                throw new InvalidStudentException("SSN should be a ninedigit number",
                                                  sSN, new ArgumentException());
            }
            this.sSN = sSN;

            if (birthday.Year < 1900 || birthday.Year > 2009)
            {
                throw new InvalidStudentException("Year should be between 1900 and 2009",
                                                  birthday.Year, new ArgumentException());
            }
            this.birthday = birthday;
        }
    }
}